#!coding:utf-8
from cvirt.cnode.libvirtXmlObject import GuestDevice

class virtualWatchdog(GuestDevice):
    ROOT_NAME = "watchdog"
    MODEL_DEFAULT = "i6300esb"
    ACTION_DEFAULT = 'reset'
    MODELS = [ "i6300esb", "ib700"]

    def __init__(self, parsexml=None):
        self.model = self.MODEL_DEFAULT
        self.action = self.ACTION_DEFAULT
        super(virtualWatchdog,self).__init__(parse_xml=parsexml)

    def _parse_xml(self, xmldoc):
        self.model = xmldoc.get('model')
        self.action = xmldoc.get('action')

    def _get_xml_config(self, root):
        if self.model:
            root.set('model',self.model)
        if self.action:
            root.set('action',self.action)
        return root